<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
		<style>
			.bluetext {
				color: blue;
			}
			.redtext {
				color: red;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<h1>通过style属性控制样式</h1>
			<div style="color: red;">Hello world!</div>
			<h1>通过class属性控制样式</h1>
			<div class="bluetext">Hello vu!</div>			
			<h1>使用Vue来控制元素的class属性</h1>
			<div :class="textColor">Hello vu!</div>
			<button @click="change">切换</button>
		</div>
		<script>
			var app = Vue.createApp({
				data() {
					return {
						textColor:{
							redtext:true,
							bluetext:false
						}
					}
				}
				,
				methods:{
					change:function()
					{
						this.textColor.redtext = !this.textColor.redtext
						this.textColor.bluetext = !this.textColor.bluetext
					}
				}
			});
			var vm = app.mount("#app")
		</script>
		
	</body>
</html>